package com.coderdream.chapter17.observer.a2;

public class IncrementalNumberGenerator extends NumberGenerator{

	private int number;//目前數值
	
	private int begin;//目前數值
	
	private int end;//目前數值
	
	private int step;//目前數值
	
	public IncrementalNumberGenerator(int begin, int end, int step) {
		this.begin = begin;
		this.end = end;
		this.step = step;
	}
	
	@Override
	public void execute() {
		for (int i = begin; i < end; i+= step) {
			number = i;
			notifyObservers();
		}	
		
	}

	@Override
	public int getNumber() {
		// TODO Auto-generated method stub
		return number;
	}

}
